feat: added configurable base directory.#826
Conversation
…` env and --base-dir flag.
…` env and --base-dir flag.
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Pull request overview
Adds a configurable “base directory” for T3 Code data storage (~/.t3 by default), exposing it via T3CODE_BASE_DIR and a --base-dir CLI flag, and updates the server/dev-runner/test harnesses so state/worktrees paths become relative to this base.
Changes:
- Introduce
baseDirinto server config and CLI/env resolution with documented precedence (--base-dir>T3CODE_BASE_DIR> default). - Move worktree location under
<baseDir>/worktreesand make default state dir relative to base (<baseDir>/userdata). - Update dev-runner + extensive test layers/harnesses to pass and use
baseDir.
Reviewed changes
Copilot reviewed 20 out of 20 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| turbo.json | Adds T3CODE_BASE_DIR to turbo global env passthrough. |
| scripts/dev-runner.ts | Adds base dir flag/env support and resolves derived dev state dir. |
| scripts/dev-runner.test.ts | Updates dev-runner env tests for new base dir behavior. |
| apps/server/src/wsServer.test.ts | Extends test server options to include baseDir. |
| apps/server/src/telemetry/Layers/AnalyticsService.test.ts | Updates test config layer to pass baseDir. |
| apps/server/src/provider/Layers/CodexAdapter.test.ts | Updates ServerConfig.layerTest calls for new signature. |
| apps/server/src/os-jank.ts | Adds resolveBaseDir + updates resolveStateDir to be base-dir aware. |
| apps/server/src/orchestration/Layers/ProviderRuntimeIngestion.test.ts | Updates ServerConfig.layerTest calls for new signature. |
| apps/server/src/orchestration/Layers/ProviderCommandReactor.test.ts | Updates harness to manage temp base dirs and pass baseDir. |
| apps/server/src/orchestration/Layers/ProjectionPipeline.test.ts | Updates projection pipeline test layers to include baseDir and temp dir cleanup. |
| apps/server/src/orchestration/Layers/OrchestrationEngine.test.ts | Updates ServerConfig.layerTest calls for new signature. |
| apps/server/src/orchestration/Layers/CheckpointReactor.test.ts | Updates ServerConfig.layerTest calls for new signature. |
| apps/server/src/main.ts | Adds --base-dir + T3CODE_BASE_DIR env parsing and resolves base/state dirs with precedence. |
| apps/server/src/git/Layers/GitManager.test.ts | Provides ServerConfig layer to satisfy GitCore’s new dependency. |
| apps/server/src/git/Layers/GitCore.ts | Moves default worktrees directory under <baseDir>/worktrees. |
| apps/server/src/git/Layers/GitCore.test.ts | Provides ServerConfig layer for GitCore tests. |
| apps/server/src/git/Layers/CodexTextGeneration.test.ts | Updates test layer creation to pass baseDir/stateDir. |
| apps/server/src/config.ts | Adds baseDir to ServerConfigShape and updates layerTest signature. |
| apps/server/integration/OrchestrationEngineHarness.integration.ts | Updates integration harness to pass base dir into test config layer. |
| apps/desktop/src/main.ts | Derives desktop state dir from T3CODE_BASE_DIR and forwards it to backend env. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
i feel like we have too many flags already 😆, would be down to just have |
|
nice, much cleaner... let me confirm the plan, removing
introducing
quick question on naming... should I go with |
|
|
|
…and `--home-dir` flag.
|
@juliusmarminge, i have updated the PR to use the simplified approach we discussed: changes made:
behavior:
|
|
Can we update the pr title based on the current solution please |
~/.t3) with T3CODE_BASE_DIR env and --base-dir flag. Fixes #748~/.t3) with T3CODE_HOME env and --home-dir flag. Fixes #748
|
Lets change the title to: |
~/.t3) with T3CODE_HOME env and --home-dir flag. Fixes #748|
description is outdated?
looks to me like we replace stateDir, correct? |
yes, description is outdated, #826 (comment) would be updated description... |
|
@macroscope-app review this |
What Changed
Added a configurable base directory for T3 Code data storage via:
T3CODE_BASE_DIRenvironment variable--base-dirCLI flagThe base directory defaults to
~/.t3, with the following paths now relative tobaseDir:userdata-> application state and SQLite databaseworktrees-> git worktree directories (existing, now uses baseDir)Path precedence:
baseDir: CLI (--base-dir) > env (T3CODE_BASE_DIR) > default (~/.t3)stateDir: CLI (--state-dir) > env (T3CODE_STATE_DIR) > default (<baseDir>/userdata)Note: If
stateDiris set explicitly (via CLI or env), it takes full priority and can be anywhere, independent ofbaseDir.Changes include:
baseDirtoServerConfigShaperesolveBaseDir()for base directory resolutionresolveStateDir()to acceptbaseDirparameter--base-dirflag to CLI (server + dev-runner)T3CODE_BASE_DIRenv var supportbaseDirWhy
Previously, all T3 Code data (worktrees, userdata, etc.) was hardcoded to
~/.t3. This change introducesT3CODE_BASE_DIR(--base-dirCLI flag) to allow users to customize the base directory.This enables:
~/.t3).t3folder in their home directory cough myself coughFixes #748
Checklist
Note
Replace
--state-dir/T3CODE_STATE_DIRwith--home-dir/T3CODE_HOMEas the configurable base directorybaseDirconcept (~/.t3by default) from which all server paths (stateDir,dbPath,attachmentsDir,logsDir,worktreesDir, etc.) are deterministically derived via a newderiveServerPathsutil in config.ts.--state-dirto--home-dirand the env var fromT3CODE_STATE_DIRtoT3CODE_HOMEacross the server, desktop app, dev runner, and documentation.ServerConfiginstead of constructing paths by joiningstateDirat call sites.ServerConfig.layerTestis updated to accept aprefixoption and create a temp base directory, replacing explicitstateDirarguments throughout the test suite.T3CODE_STATE_DIRis no longer read; existing overrides using that env var will silently have no effect.Macroscope summarized 1b462fd.